﻿/*
 * LeafLegendNode
 * 
 * initial implementation : 20.10.2008
 *
 * Copyright (c) Adam Sida, asida@centrum.cz.
 * All rights reserved.
 * 
 * for license see Petra.Gis.License.txt
 */
using System;

namespace Petra.Gis.RenderingServices.PlanarBase 
{

  /// <summary>
  /// Legend node that contains child legend nodes, called also as GroupNode or LeafNode.
  /// This is also the only object in legend, that can be used to add new sub items into (or remove from).
  /// </summary>
  public class LeafLegendNode : LegendNodeBase
  {


    #region ctor

    ///// <summary>
    ///// List of child nodes for current <c>LeafLegendNode</c>
    ///// </summary>
    //protected LegendChildNodes childNodes;
    //protected DisplayOrder _legendDisplayOrder;



    /// <summary>
    /// xaml constr.
    /// </summary>
    public LeafLegendNode()
      :base()
    {
      //childNodesData = new List<LegendNodeBase>();
      ChildNodes = new LegendChildNodes(this);
      NodeType = LegendNodeTypeEnum.GroupNode;
    }





    /// <summary>
    /// Creates new instance of <c>LeafLegendNode</c> for given parent node
    /// </summary>
    /// <param name="parent">parent node to add leaf node into</param>
    /// <param name="title">title of new <c>LeafLegendNode</c></param>
    public LeafLegendNode(LeafLegendNode parent, string title)
      :base(parent, title)
    {
      //childNodesData = new List<LegendNodeBase>();
      ChildNodes = new LegendChildNodes(this);
      NodeType = LegendNodeTypeEnum.GroupNode;
    }


    #endregion ctor




    /// <summary>
    /// List of child nodes for current node.
    /// </summary>
    public LegendChildNodes ChildNodes
    { get; protected set; }




    //public LegendNodeBase AppendChild(LegendNodeBase newChild)
    //{
    //  ////if (_nodeType != LegendNodeType.GroupNode)
    //  ////  throw new InvalidOperationException("invalid command");

    //  //// if parent of newChild is not null then remove it from prev
    //  //if (newChild.ParentNode() != null)
    //  //  // reinsert existing node into another place
    //  //  // display order remains same
    //  //  // so must use removeNode instead of RemoveNode
    //  //  ((LeafLegendNode)newChild.ParentNode()).RemoveNode(newChild, false);
    //  //else
    //  //  // new node insert, put into displayOrder collection
    //  //  _legendDisplayOrder.Insert(0, newChild);

    //  //add to current collection
    //  _data.Add(newChild);

    //  newChild.ParentNode = this;

    //  return newChild;
    //}




    ///// <summary>
    ///// removes node based on criteria
    ///// </summary>
    ///// <param name="childToRemove">child node</param>
    ///// <param name="removeFromDisplayOrder">remove also from display order</param>
    ///// <returns>removed node instance</returns>
    //public LegendNodeBase RemoveChild(LegendNodeBase childToRemove, bool removeFromDisplayOrder)
    //{
    //  if(!this.ChildNodes.Contains(childToRemove))
    //    throw new ArgumentException("not a member");

    //  ChildNodes.Remove(childToRemove, removeFromDisplayOrder);

    //  //if (removeFromDisplayOrder)
    //  //  _legendDisplayOrder.Remove(childToRemove);

    //  return childToRemove;
    //}





  }

}
